<template>
  <div class="demo">
    <div class="demo-title">带斑马纹表格</div>
    <div class="demo-content">
      <Table
        class="sscd-table"
        size="middle"
        :columns="columns"
        :data-source="data"
        :row-class-name="(_record, index) => (index % 2 === 1 ? 'table-striped' : '')"
      />
      <Table
        class="sscd-table"
        size="middle"
        :columns="columns"
        :data-source="data"
        :row-class-name="(_record, index) => (index % 2 === 1 ? 'table-striped' : '')"
        bordered
      />
    </div>
  </div>
</template>

<script lang="ts" setup>
  import Table from '@sscd/table';
  const columns = [
    { title: 'Name', dataIndex: 'name' },
    { title: 'Age', dataIndex: 'age' },
    { title: 'Address', dataIndex: 'address' },
  ];
  const data = [
    {
      key: '1',
      name: 'John Brown',
      age: 32,
      address: 'New York No. 1 Lake Park',
    },
    {
      key: '2',
      name: 'Jim Green',
      age: 42,
      address: 'London No. 1 Lake Park',
    },
    {
      key: '3',
      name: 'Joe Black',
      age: 32,
      address: 'Sidney No. 1 Lake Park',
    },
    {
      key: '4',
      name: 'Ben Kang',
      age: 15,
      address: 'Sidney No. 1 Lake Park',
    },
  ];
</script>

<style scoped lang="less">
  .sscd-table {
    :deep(.table-striped) {
      td {
        background-color: #fafafa;
      }
    }
  }
</style>
